import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '/app/bindings/initial_binding.dart';
import '/app/core/values/app_colors.dart';
import '/app/routes/app_pages.dart';
import '/flavors/build_config.dart';
import '/flavors/env_config.dart';

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  final EnvConfig _envConfig = BuildConfig.instance.config;

  @override
  Widget build(BuildContext context) {

    SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
        statusBarColor: Colors.transparent,    //状态栏背景颜色
        statusBarIconBrightness: Brightness.light // dark:一般显示黑色   light：一般显示白色
    ));

    return ScreenUtilInit(
      designSize: const Size(1920, 1080),
      builder: (_, child){
        return GetMaterialApp(
          title: _envConfig.appName,
          initialRoute: AppPages.INITIAL,
          initialBinding: InitialBinding(),
          getPages: AppPages.routes,
          localizationsDelegates: AppLocalizations.localizationsDelegates,
          supportedLocales: _getSupportedLocal(),
          theme: ThemeData(
            primarySwatch: AppColors.colorPrimarySwatch,
            visualDensity: VisualDensity.adaptivePlatformDensity,
            brightness: Brightness.light,
            primaryColor: AppColors.colorPrimary,
            textTheme: const TextTheme(
              labelLarge: TextStyle(
                color: Colors.white,
                fontSize: 20.0,
                fontWeight: FontWeight.bold,
              ),
            ),
            appBarTheme: const AppBarTheme(
                backgroundColor: Colors.white,
                elevation: 0,  //隐藏AppBar底部的阴影分割线
                systemOverlayStyle: SystemUiOverlayStyle(
                    statusBarColor: Colors.transparent
                )
              //SystemUiOverlayStyle.light //设置状态栏的背景
            ),
            fontFamily: 'Roboto',
          ),
          debugShowCheckedModeBanner: false,
        );
      },
    );


  }

  List<Locale> _getSupportedLocal() {
    return [
      const Locale('en', ''),
      const Locale('bn', ''),
    ];
  }
}
